package com.chief.hadoop.mr.combine;

import com.chief.hadoop.mr.writable.FlowBean;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class FlowMapper extends Mapper<LongWritable, Text, Text, FlowBean> {

    Text outKey = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] split = line.split("\t");
        outKey.set(split[1]);
        context.write(outKey, new FlowBean(Long.valueOf(split[split.length - 3]), Long.valueOf(split[split.length - 2])));
    }
}
